package com.healthcloud.tag;

import java.io.IOException;
import java.io.StringWriter;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.healthcloud.entity.SysConfigEntity;
import com.healthcloud.service.SysConfigService;
import com.healthcloud.utils.SpringUtil;

/**
 * 下拉枚举选项
 * @author zj
 *
 */
public class ConfigValTag extends SimpleTagSupport {

	private String name;
	
	private String key;
	
    private SysConfigService sysConfigService = (SysConfigService) SpringUtil.getBean("sysConfigService");

	public void setName(String name) {
		this.name = name;
	}

	public void setKey(String key) {
		this.key = key;
	}

	StringWriter sw = new StringWriter();

	public void doTag() throws JspException, IOException {
		JspWriter out = getJspContext().getOut();
		if (StringUtils.isNotEmpty(name)&&StringUtils.isNotEmpty(key)) {
			SysConfigEntity entity = sysConfigService.queryByNameAndKey(name, key);
			if (entity!=null) {
				out.println(entity.getValue());
			}
		}
	}

}
